﻿@model App.Models.SysSample
@using App.Common;
@using App.Models;

@{
    ViewBag.Title = "编辑";
    Layout = "~/Views/Shared/Edit.cshtml";
}

@using (Html.BeginForm("Edit", "Home", null, FormMethod.Post, new { Id = "EditForm" }))
{
    @Html.ValidationSummary(true)
    <table class="detail setTextWidth200">
        <tbody>
            <tr>
                <td style="width: 100px; text-align: right;">
                    @Html.LabelFor(model => model.Id)：
                </td>
                <td>
                    @Html.EditorFor(model => model.Id)
                </td>
                <td>
                    @Html.ValidationMessageFor(model => model.Id)
                </td>

                <td style="width: 100px; text-align: right;">
                    @Html.LabelFor(model => model.Name)：
                </td>
                <td>
                    @Html.EditorFor(model => model.Name)
                </td>
                <td>
                    @Html.ValidationMessageFor(model => model.Name)
                </td>
            </tr>
            <tr>
                <td style="width: 100px; text-align: right;">
                    @Html.LabelFor(model => model.Age)：
                </td>
                <td>
                    @Html.EditorFor(model => model.Age)
                </td>
                <td>
                    @Html.ValidationMessageFor(model => model.Age)
                </td>

                <td style="width: 100px; text-align: right;">
                    @Html.LabelFor(model => model.Bir)：
                </td>
                <td>
                    @Html.TextBoxFor(model => model.Bir)
                </td>
                <td>
                    @Html.ValidationMessageFor(model => model.Bir)
                </td>
            </tr>

            <tr>
                <td style="width: 100px; text-align: right;">
                    @Html.LabelFor(model => model.Note)：
                </td>
                <td>
                    @Html.EditorFor(model => model.Note)
                </td>
                <td>
                    @Html.ValidationMessageFor(model => model.Note)
                </td>

                <td style="width: 100px; text-align: right;">
                    @Html.LabelFor(model => model.CreateTime)：
                </td>
                <td>
                    @Html.TextBoxFor(model => model.CreateTime)
                </td>
                <td>
                    @Html.ValidationMessageFor(model => model.CreateTime)
                </td>
            </tr>
            <tr>
                <td style="width: 100px; text-align: right;">
                    @Html.LabelFor(model => model.Photo)：
                </td>
                <td>
                    @Html.TextBoxFor(model => model.Photo)
                </td>
                <td>
                    @Html.ValidationMessageFor(model => model.Photo)
                </td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </tbody>
    </table>
}

<script type="text/javascript">
    $(function () {
        $("#EditForm").form({
            url: "Home/Edit"
        });
        $.extend(dialog.opgions, {
            onSave: Save,
            onAdd: RedirectAddView,
            onRemove: function () { $.messager.alert('温馨提示', 'Remove!remove url:Home/Remove?data=data'); },
            onDetail: RedirectDetailView,
        });
    });

    function Save() {
        $('#EditForm').form('submit', {
            success: function (data) {
                if (data)
                    $.messager.alert('温馨提示', '更新成功！');
                else
                    $.messager.alert('温馨提示', '更新失败！');
            }
        });
    }

    function RedirectAddView() {
        if (isBrowserNewTab) {
            window.location.href = "../Home/Create?isBrowserNewTab=True";
        } else {
            $("#editView").dialog('close');
            createView('Home/Create');
        }
    }

    function RedirectDetailView() {
        if (isBrowserNewTab) {
            window.location.href = "../Home/Detail?isBrowserNewTab=True";
        } else {
            $("#editView").dialog('close');
            createView('Home/Detail');
        }
    }
</script>
